import { post } from '@common/ajax';
import { SHOP_URL } from '@common/url';

import { GET_PREFECTURE_LIST } from '@store/mutationType';

const prefecture = {
    state: {
        goodsList: [],
    },
    mutations: {
        GET_PREFECTURE_LIST: (state, goodsList) => {
            Object.assign(state, { goodsList });
        },
    },
    actions: {
        // 获取专区列表
        getPrefectureGoodsList: async ({ commit }, { ids = [], storeId = 0 }) => {
            const res = await post(SHOP_URL.prefectureList, {
                id: storeId,
                prod_ids: ids,
            });
            commit(GET_PREFECTURE_LIST, res.prods);
        },
    },
};

export default prefecture;
